﻿@using Entidades.Sistema.Venta;
@using Entidades.Sistema.Base;
@using System.Collections.ObjectModel;


@Html.DevExpress().CallbackPanel(
    settings => {
        settings.Name = "cbpProducto";
        settings.CallbackRouteValues = new { Controller = "EmpleadoProducto", Action = "ListBoxProductos" };
        settings.SetContent(() => 
            {
                Html.DevExpress().ListBox(
                settings2 =>
                {
                    settings2.Name = "lbProducto";
                    settings2.Width = 300;
                    settings2.Height = 350;
                    settings2.Properties.SelectionMode = ListEditSelectionMode.CheckColumn;
                    settings2.Properties.ValueField = "IdProducto";
                    settings2.Properties.ValueType = typeof(string);
                    settings2.Properties.Columns.Add("Nombre", "Nombre").Width = Unit.Percentage(100);
                    settings2.PreRender = (sender, e) =>
                    {
                        MVCxListBox cbl = (MVCxListBox)sender;
                        foreach (ListEditItem item in cbl.Items)
                        {

                            foreach (Producto p in Model.Productos)
                                {
                                    if (p.IdProducto.ToString() == item.Value.ToString())
                                    {
                                        item.Selected = true;
                                    }
                                }     
                        }

                    };
                }
                ).BindList(ViewBag.Productos).GetHtml();
            });
        settings.ClientSideEvents.BeginCallback = "OnBeginCallback";
        settings.ClientSideEvents.EndCallback = "OnEndCallback";
    }
).GetHtml()
        
